<template>
	<view>
		<detailPage
			:pageUrl="pageUrl"
			:editFormOptions="editFormOptions"
			:editFormFields="editFormFields"
			:detailColumns="detailColumns"
			@masterDate="masterDate"
			:titel="titel"
		></detailPage>
	</view>
</template>
<script>
export default {
	data() {
		return {
			titel: '',
			pageUrl: 'q_sales',
			editFormFields: {
				Voucher_sub: '',
				Client: '',
				Project_name: '',
				Sales_contract_voucher_sub: '',
				Goods_num: '',
				Total_price: ''
			},
			editFormOptions: [
				{
					title: '订单编码',
					field: 'Voucher_sub',
					readonly: true
				},
				{
					title: '客户',
					field: 'Client',
					readonly: true,
					data: [],
					key: '审核通过客户'
				},
				{
					title: '项目名称',
					field: 'Project_name',
					readonly: true
				},
				{
					title: '销售合同',
					field: 'Sales_contract_voucher_sub',
					readonly: true
				},
				{
					title: 'ID',
					required: true,
					field: 'Sales',
					hidden: true,
					readonly: true
				},
				{
					title: '销售数量',
					field: 'Goods_num',
					readonly: true,
					type: 'number'
				},
				{
					title: '销售总价',
					field: 'Total_price',
					readonly: true
				}
			],
			detailColumns: [
				{
					field: 'SalesList',
					title: 'ID',
					hidden: true
				},
				{
					field: 'WHSE_name',
					title: '库位名称',
					readonly: true,
					data: [],
					key: '库位编码',
					type: 'select'
				},
				{
					field: 'Sales_contract_voucher_sub',
					title: '销售合同编码',
					type: 'string',
					readonly: true
				},
				{
					field: 'Goods_sub',
					title: '商品编码',
					type: 'string',
					readonly: true
				},
				{
					field: 'Goods_name',
					title: '商品名称',
					type: 'string',
					readonly: true
				},
				{
					field: 'Goods_size',
					title: '规格型号',
					type: 'string',
					readonly: true
				},
				{
					field: 'Goods_num',
					title: '销售数量',
					type: 'int',
					readonly: true
				},
				{
					field: 'Goods_price',
					title: '销售单价',
					type: 'int',
					readonly: true
				},
				{
					field: 'Total_price',
					title: '销售金额',
					type: 'string',
					readonly: true
				},
				{
					field: 'Tax_exclusive_contract_total_price',
					title: '销售无税金额',
					type: 'string',
					readonly: true
				},
				{
					field: 'SN',
					title: 'SN码',
					type: 'string',
					readonly: true
				},
				{
					field: 'Remark',
					title: '备注',
					type: 'string',
					readonly: true
				}
			]
		};
	},
	onLoad() {
		this.detailColumns.forEach((obj) => {
			if (obj.type == 'select') {
				this.http.post('api/Sys_Dictionary/GetVueDictionary', [obj.key], true).then((result) => {
					if (result.length) {
						for (var index = 0; index < result.length; index++) {
							if (result[index].dicNo == obj.key) {
								obj.data = result[index].data;
							}
						}
					}
				});
			}
		});
	},
	methods: {
		masterDate(val) {
			Object.assign(this.editFormFields, val);
		}
	}
};
</script>
